import React, { useEffect, useState } from 'react'
import { Cascader } from 'antd';
import axios from 'axios';
export default function Index(props) {
  const [option,setOption] = useState([])
  useEffect(async () => {
    const resp = await axios.get("http://localhost:8080/qryType")
    console.log(resp);
    let rs = resp.data.data.map((item, index) => {
      return {

        value: item.fathername,
        label: item.fathername,
        children:
          item.children.map((item, index) => {
            return (
              {

                value: item.childname,
                label: item.childname
              }
            )

          })
      }
    })
    setOption(rs);
  }, [])

  function onChange(value) {
    console.log(value);
  }
  return (
    <Cascader options={option} style={props.style} onChange={props.onChange || onChange} placeholder={props.title || "物品类别"} />
  )
}
